﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace wesiGestClinica.actplansalud.popups
{
    public partial class FormsPopupBuscarEmpresa : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = 0;
            Response.CacheControl = "no-cache";
            Page.Header.Controls.Add(new LiteralControl(@"<base target=""_self"" />"));
            if (!Page.IsPostBack)
            {
                Session["arrConEmp"] = null;
            }
            ucEmpresa.dgEmpresas.RowCommand += new GridViewCommandEventHandler(dgEmpresas_RowCommand);
        }

        void dgEmpresas_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Seleccionar")
            {
                GridViewRow fila = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer;
                ucEmpresa.dgEmpresas.SelectedIndex = fila.RowIndex;
                string[] arr = e.CommandArgument.ToString().Split(new char[] { '|' });
                Session.Add("arrConEmp", arr);
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Envio", "enviarParam('" + arr[0] + "','" + arr[1] + "');", true);
            }
        }
    }
}
